package com.cxyxj.componentscan.app;

import com.cxyxj.componentscan.impl.CustomTypeFilter;
import com.cxyxj.componentscan.impl.UserServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

/**
 * @author: gongj
 * @create: 2022-02-14 11:16
 */
@ComponentScan(basePackages = "com.cxyxj.componentscan.app",
        basePackageClasses = {UserServiceImpl.class},
        useDefaultFilters = false,
        includeFilters = @ComponentScan.Filter(type = FilterType.CUSTOM,value = {CustomTypeFilter.class})
)
public class AppMain {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppMain.class);
        // 打印 bean 名称
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String name : beanDefinitionNames){
            System.out.println(name);
        }

    }
}
